/*
题目链接:https://leetcode.cn/problems/sum-of-all-subset-xor-totals/description/?envType=daily-question&envId=2025-04-05
*/

//题解代码:

class Solution {
public:
    int subsetXORSum(vector<int>& nums) {
        int ans = 0;
        int n = nums.size();

        auto dfs = [&](auto&& dfs,int i,int x)->void{
            if(i==n){
                ans += x;
                return;
            }
            dfs(dfs,i+1,x^nums[i]);
            dfs(dfs,i+1,x);
        };

        dfs(dfs,0,0);

        return ans;
    }
};
